{% extends "layouts/backoffice.html" %}
{% block title%}基金基本資料查詢{% endblock %}
{% block content%}
{% load humanize %}
  
<div class="nav">
  <h1>基金基本資料維護</h1>
  <div class="menuGroup">
    <span class="menuButton">
    	<a class="button" href="javascript:window.location.href='/fundata/create/'">新增基金</a>
    	<a class="button" href="javascript:window.location.href='/fundata/updateNetValue/'">更新淨值</a>
    </span>
  </div>
</div>
<div class="body">
  <div class="list">
    <table>
      <thead>
      <tr>
        <th>基金名稱</th>
        <th>交易<br/>類型</th>
        <th>幣別</th>              
        <th>上一次淨值日期</th>
        <th>上一次淨值</th>
        <th>最新淨值日期</th>        
        <th>最新淨值</th>
        <th>增減(%)</th>
        <th>開始投資日</th>
        <th>投資金額</th>
        <th>交易淨值</th>
        <th>單位數</th>
	  	<th>參考現值</th>
        <th>手續費</th>
        <th>損益</th>
         <th>報酬率(%)</th> 
        <th>更新時間</th>       	 
        <th>策略</th>
        <th>刪除</th>
      </tr>
      </thead>
      <tbody>
      {% for data in funds %}
        <tr>
          <td><a href="javascript:window.location.href='/fundata/{{data.fundObj.key}}/'">{{data.fundObj.name}}</a></td>
          <td>
          	{% ifequal data.fundObj.type "Once" %}
          		單筆
          	{% else %}
          		定期定額
          	{% endifequal %}
          </td>
          <td>{{data.fundObj.currency}}</td>          
          <td>{{data.preNetDate}}</td>
           <td>{{data.preNetValue|intcomma}}</td>
         <td>{{data.lastNetDate}}</td>
           <td>{{data.lastNetValue|intcomma}}</td>
           <td class="datarate">{{data.diffValue|floatformat:"-2"}}</td> 
           <td>{{data.fundObj.startDate}}</td>
            <td>{{data.fundObj.amount|intcomma}}</td>
          <td>{{data.fundObj.buyNetValue|intcomma}}</td>
          <td>{{data.fundObj.buyCount|intcomma}}</td>
          <td>{{data.currentAmount|intcomma}}</td>
          <td>{{data.charge}}</td>
          <td>{{data.profit|intcomma}}</td>
          <td class="datarate">{{data.return|floatformat:"-2"}}</td>
          <td>{{data.lastUpdated|date:"Y/m/d H:s"}}</td>
          <td>{{data.strategy}}</td>
          <td><a href="javascript:window.location.href='/fundata/{{data.obj.key}}/delete/'" onclick="return confirm('是否確定刪除?');">刪除</a></td>
        </tr>
      {% endfor %}
      </tbody>
    </table>
  </div>  
</div>
<script>
	$().ready(function(){
		$(".datarate").each(function(){
			var d = $(this).text();			
			if (d != '' && d.substring(0,1) == '-'){
				$(this).addClass("down");
			}else if (d != ''){
				$(this).addClass("up");
			}
		})	
	})

</script>
{% endblock %}